package cn.edu.scau.cmi.yewangjiang.composite.safe;
import java.util.ArrayList;
import java.util.List;

public class Team extends Organization{
    private String name;
    private Organization parent;
    private List<Organization> children;
    public Team() {
    	children=new ArrayList<Organization>();
    }
    public Team(String name) {
    	setName(name);
    	children=new ArrayList<Organization>();
    }
    public void setName(String name) {
    	this.name=name;
    } 
    public String getName() {
    	return this.name;
    }
    public void setParent(Organization p) {
    	parent=p;
    }
    @Override
    public Organization getParent() {
    	return parent;
    }
    public void setChildren(List list) {
    	children=list;
    }
    public List<Organization> getChildren(){
    	return children;
    }
    public boolean addChild(Organization o) {
    	if(o instanceof Team) {
    		Team team=(Team)o;   		
    		team.setParent(this);
    	}
    	if(o instanceof Person) {
    		Person person=(Person)o;
    		person.setParent(this);
    		
    	}
    	children.add(o);
    	return true;
    }
    public boolean removeChild(Organization o) {
    	boolean flag=children.remove(o);
    	return flag;
    }
}
